import java.util.HashSet;
import java.util.Set;

public class Solution804 {
    public int uniqueMorseRepresentations(String[] words) {
        String[] s=new String[]{".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."};
        Set<String> set=new HashSet<>();
        for (String word : words) {
            StringBuilder stringBuilder=new StringBuilder();
            for (char c : word.toCharArray()) {
                stringBuilder.append(s[c-'a']);
            }
            set.add(stringBuilder.toString());
        }
        return set.size();
    }

    public static void main(String[] args) {
        System.out.println(new Solution804().uniqueMorseRepresentations(new String[]{"gin", "zen", "gig", "msg"}));
    }

}
